function queryAllDetail(basePath,sortId) {
    $.ajax({
        url:basePath+"/queryAllDetail",
        type:"post",
        data:{sortId:sortId},
        dateType:"json",
        success:function (result) {
            $(".content").remove();
            $(result).each(function () {
                var tr="<tr class=\"content\" style='text-align: center'>\n" +
                    "                <td>"+this.id+"</td>\n" +
                    "                <td>"+this.name+"</td>\n" +
                    "                <td>"+this.sortName+"</td>\n" +
                    "                <td>"+this.address+"</td>\n" +
                    "                <td>"+this.createDate+"</td>\n" +
                    "                <td>"+this.price+"</td>\n" +
                    "                <td>"+this.remaining+"</td>\n" +
                    "                <td><a href=\""+basePath+"/shopGoods?id="+this.id +"\">购买</a></td>\n" +
                    "            </tr>";
                $("#tb").append(tr);
            })
            $(".content:even").css("background-color","#A0A59F")
        }
        }
    )
}
$(function () {
    //获取项目的根路径
    var basePath = $("#basePath").val();
    var sortId = 0;
    $.ajax({
        url:basePath+"/queryAllSort",
        type:"post",
        dateType:"json",
        success:function (result) {
            $(result).each(function () {
                var str="<option value='"+this.id+"'>"+this.name+"</option>";
                $("#sort").append(str);
            })
        }
    })
    //查询所有的商品
    queryAllDetail(basePath,sortId);

    $("#sort").change(function () {
        sortId=$(this).val();
        queryAllDetail(basePath,sortId);
    })
})